package view;

import java.awt.Frame;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.sql.SQLException;

import modle.User;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;

public class TaskFrame extends JFrame implements WindowListener {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	User user = new User();
	JTabbedPane tabbedPane = new JTabbedPane();
	UserPanel userPanel = new UserPanel(this);
	TaskPanel taskPanel = new TaskPanel(this);
	EventPanel eventPanel = new EventPanel(this);
	EmailPanel emailPanel = new EmailPanel(this);

	public TaskFrame() throws SQLException {
		this.setTitle("TaskHelper");
		this.setExtendedState(Frame.MAXIMIZED_BOTH);
		this.addWindowListener(this);

		tabbedPane.addTab("User", userPanel);
		tabbedPane.addTab("Task", taskPanel);
		tabbedPane.addTab("Event", eventPanel);
		tabbedPane.addTab("Email", emailPanel);

		this.add(tabbedPane);
		init();
	}

	public EmailPanel getEmailPanel() {
		return emailPanel;
	}

	public EventPanel getEventPanel() {
		return eventPanel;
	}

	public JTabbedPane getTabbedPane() {
		return tabbedPane;
	}

	public TaskPanel getTaskPanel() {
		return taskPanel;
	}

	public User getUser() {
		return user;
	}

	public UserPanel getUserPanel() {
		return userPanel;
	}

	public void init() {
		userPanel.init();
		taskPanel.init();
		eventPanel.init();
		emailPanel.init();

		tabbedPane.setEnabledAt(1, false);
		tabbedPane.setEnabledAt(2, false);
		tabbedPane.setEnabledAt(3, false);

	}

	public void setUser(User user) {
		this.user = user;
	}

	public void windowActivated(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	public void windowClosed(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	public void windowClosing(WindowEvent arg0) {
		// TODO Auto-generated method stub
		System.exit(0);
	}

	public void windowDeactivated(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	public void windowDeiconified(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	public void windowIconified(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	public void windowOpened(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

}
